//
//  AboutUsViewController.m
//  EasyToTesco
//
//  Created by mc on 16/2/29.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "AboutUsViewController.h"
#import "HeaderFileForEasyToTesco.h"
#import "AFNetworking.h"

@interface AboutUsViewController ()

@end

@implementation AboutUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self addAboutUsTopView];
    
    [self addAboutUsUI];
    
    [self Aboutdatasources];
    
    
}
- (void)addAboutUsTopView {
    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, (self.secondView.frame.size.height-20)/2, 20, 20)];
    image1.image = [UIImage imageNamed:@"goback-icon.png"];
    [self.secondView addSubview:image1];
    self.leftBtn.hidden = YES;
    
    UIButton *goBackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    goBackBtn.frame = CGRectMake(0, 0, self.secondView.frame.size.height, self.secondView.frame.size.height);
    [goBackBtn addTarget:self action:@selector(gobackClick) forControlEvents:UIControlEventTouchUpInside];
    [self.secondView addSubview:goBackBtn];
    self.titleLabel.text = @"关于我们";
}

- (void)gobackClick {
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)addAboutUsUI{
    UIImageView *picImage = [[UIImageView alloc] initWithFrame:CGRectMake((WEITH - 80)/2, HIGHT*0.1+40, 80, 80)];

    picImage.image = [UIImage imageNamed:@"icon_login"];
    picImage.layer.cornerRadius = 9;
    picImage.layer.masksToBounds = YES;
    [self.view addSubview:picImage];
    
    
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(picImage.frame)+10, WEITH, 40)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"亿乐购";
    titleLabel.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:titleLabel];
    
    UILabel *versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame)+10, WEITH, 40)];
    versionLabel.font = [UIFont systemFontOfSize:16];
    versionLabel.textAlignment = NSTextAlignmentCenter;
    NSString *temp = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];      //获取项目版本号
    versionLabel.font = [UIFont systemFontOfSize:16];
    versionLabel.text = [NSString stringWithFormat:@"当前版本:%@", temp];
    [self.view addSubview:versionLabel];
    
    
    UILabel *copyrightlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, WEITH, HIGHT*0.8, 30)];
    copyrightlabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:copyrightlabel];
    
}



- (void)Aboutdatasources{
        AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
    mgr.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    NSString *temp = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];      //获取项目版本号
    NSString *v = @"1.0.0";//temp;

    NSLog(@"%@", temp);
    
    NSDictionary *param = @{ @"v":[NSString stringWithFormat:@"%@", v]};
    
    [mgr POST:@"http://www.ylgw8.com/AppPub/Check" parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        
        
    
        NSLog(@"");
      
    } failure:^(AFHTTPRequestOperation *operation,NSError *error)
     {
         //         operation.response.statusCode;//404 401之类
//         NSLog(@"数据请求错误原因:%@", error);
//         NSLog(@"数据请求错误码:%ld", (long)operation.response.statusCode);
     }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
